// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es6id: 12.2.6.9
description: Assignment of function `name` attribute (ArrowFunction)
info: |
    6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
       a. Let hasNameProperty be HasOwnProperty(propValue, "name").
       b. ReturnIfAbrupt(hasNameProperty).
       c. If hasNameProperty is false, perform SetFunctionName(propValue,
          propKey).
includes: [propertyHelper.js]
features: [Symbol]
---*/

function Test() {
    var namedSym = Symbol('test262');
    var anonSym = Symbol();
    var o;

    o = {
      id: () => {},
      [anonSym]: () => {},
      [namedSym]: () => {}
    };

    assert.sameValue(o.id.name, 'id', 'via IdentifierName');
    verifyNotEnumerable(o.id, 'name');
    verifyNotWritable(o.id, 'name');

    assert.sameValue(o[anonSym].name, '', 'via anonymous Symbol');
    verifyNotEnumerable(o[anonSym], 'name');
    verifyNotWritable(o[anonSym], 'name');

    assert.sameValue(o[namedSym].name, '[test262]', 'via Symbol');
    verifyNotEnumerable(o[namedSym], 'name');
    verifyNotWritable(o[namedSym], 'name');
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
